package adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.NoteCategoryBean;
import student.andlei.com.student.R;
import utils.GlideUtils;
import utils.StringUtils;

public class NoteAdapter extends BaseQuickAdapter<NoteCategoryBean,BaseViewHolder>{
    private Context context;
    public NoteAdapter(Context context, int layoutResId, @Nullable List data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, NoteCategoryBean item) {
        if(!StringUtils.isNull(item.image)){
            GlideUtils.loadImageViewNoteLoding(context,item.image, (ImageView) helper.getView(R.id.img_content));
        }else {
            ((ImageView) helper.getView(R.id.img_content)).setImageBitmap(null);
        }
        helper.setText(R.id.tv_note_title, StringUtils.isNull(item.title)?"-":item.title);
        helper.setText(R.id.tv_note_content, StringUtils.isNull(item.content)?"-":item.content);
        helper.setText(R.id.tv_note_time, StringUtils.isNull(item.create_time)?"-":item.create_time);
        if(item.isWaste){
            helper.getView(R.id.ll_basket_list).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.ll_basket_list).setVisibility(View.GONE);
        }
        helper.addOnClickListener(R.id.bt_delete);
        helper.addOnClickListener(R.id.bt_reduction);
    }


}
